<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:66:"F:\yxl\tp5.com\public/../application/admin\view\rule\rule_add.html";i:1561118397;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>layout 后台大布局 - Layui</title>
    <link rel="stylesheet" href="/static/layui/css/layui.css">
</head>
<body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
    <legend>权限添加</legend>
</fieldset>

<form class="layui-form" action="">
    <div class="layui-form-item">
        <label class="layui-form-label">权限所属</label>
        <div class="layui-input-inline">
            <select name="pid" lay-verify="">
                <option value=""></option>
                <option value="0">顶级分类</option>
                <?php foreach($rules as $vc): ?>
                <option value="<?php echo $vc['id']; ?>"><?php echo $vc['title']; ?></option>
                <?php endforeach; ?>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">路由</label>
        <div class="layui-input-inline">
            <input type="text" name="name" autocomplete="off"  class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">权限名称</label>
        <div class="layui-input-inline">
            <input type="text" name="title" autocomplete="off"  class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">状态</label>
        <div class="layui-input-inline">
            <input type="checkbox" name="status" lay-skin="switch">
        </div>
    </div>


    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="demo">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>



</body>
<script src="/static/layui/layui.js"></script>
<script>
    layui.use(['jquery','form'], function(){

        var jquery = layui.jquery;
        var form = layui.form;

        //监听提交
        form.on('submit(demo)',function(data){
            //alert(data.filed);
            jquery.post("/admin/rule/ruleAddDo",data.field,function(res){
                if(res.code == 1 ){
                    layer.msg('添加成功',{icon:1,time:1000},function(){
                        window.parent.location.reload();
                    });
                }else{
                    layer.msg('添加失败');
                }
            });
            return false;
        });
    });
</script>
</html>